home *** CD-ROM | disk | FTP | other *** search
- #include <QDOffScreen.h>
- #include "IconUtil.h"
-
- #define ICONID 128
-
-
- /* this program shows how to take any size pixmap and scale it down to any size or depth icon. */
- /* By Brigham Stevens
- 2-6-92
- Apple Computer Developer Technical Support
- */
-
- main()
- {
-
- CWindowPtr cwp;
- Handle icon;
- Handle iconMask;
- GWorldPtr gwp;
- Handle h;
- Rect demo;
- short ref,err;
- long iconSize;
-
-
- InitToolBox(4); // Witch Chant + 4 calls to More Masters
-
- /* load map of earth in color - no hilite palette */
- cwp = GetNewCWindow(128,NIL,(void*)-1L);
- gwp = LoadPictToGWorld(128, cwp, 256, 8, 8, true);
- SetWTitle(cwp,"\pFlailing about rapidly contorting");
- ShowWindow(cwp);
- DrawImage(cwp);
-
- while(!Button()); // after a click then we make a small icon thang....
- FlushEvents(everyEvent,0);
- SetRect(&demo,100,100,132,132); // this is the area of pixmap we make icon from
- // it can be the entire portRect if we want
-
-
-
- ref = OpenResFile("\pMakeIcon.output"); // THIS FILE MUST EXIST, or we may croak
- if(ResError()) ExitToShell();
-
- icon = MakeIcon(gwp,&demo,1,32); // make 32x32 1-bit color icon
-
- if(icon)
- {
- TryRemoveResource('ICON',ICONID);
- AddResource( icon, 'ICON', ICONID, "\p");
- CheckError("\pAddResFail ICON",ResError());
- }
-
- icon = MakeIcon(gwp,&demo,1,16); // make 16x16 1-bit color icon
-
- if(icon)
- {
- TryRemoveResource('SICN',ICONID);
- AddResource( icon, 'SICN', ICONID, "\p");
- CheckError("\pAddResFail SICN",ResError());
- }
-
- icon = MakeICN_pound(gwp, &demo, 32); // create 32x32 1-bit color icon AND MASK
- if(icon)
- {
- TryRemoveResource('ICN#',ICONID);
- AddResource( icon, 'ICN#', ICONID, "\p");
- CheckError("\pAddResFail ICN#",ResError());
- }
-
- icon = MakeICN_pound(gwp, &demo, 16); // create 16x16 1-bit color icon AND MASK
- if(icon)
- {
- TryRemoveResource('ics#',ICONID);
- AddResource( icon, 'ics#', ICONID, "\p");
- CheckError("\pAddResFail ics#",ResError());
- }
-
- icon = MakeIcon(gwp,&demo,8,32); // make 32x32 8-bit color icon
-
- if(icon)
- {
- TryRemoveResource('icl8',ICONID);
- AddResource( icon, 'icl8', ICONID, "\p");
- CheckError("\pAddResFail icl8",ResError());
- }
-
- icon = MakeIcon(gwp,&demo,4,32); // make 32x32 4-bit color icon
-
- if(icon)
- {
- TryRemoveResource('icl4',ICONID);
- AddResource( icon, 'icl4', ICONID, "\p");
- CheckError("\pAddResFail icl4",ResError());
- }
-
-
- icon = MakeIcon(gwp,&demo,8,16); // make 16x16 8-bit color mask
-
- if(icon)
- {
- TryRemoveResource('ics8',ICONID);
- AddResource( icon, 'ics8', ICONID, "\p");
- CheckError("\pAddResFail ics8",ResError());
- }
-
- icon = MakeIcon(gwp,&demo,4,16); // make 16x16 4-bit color mask
-
- if(icon)
- {
- TryRemoveResource('ics4',ICONID);
- AddResource( icon, 'ics4', ICONID, "\p");
- CheckError("\pAddResFail ics4",ResError());
- }
-
- CloseResFile(ref);
- }
-
-
-